export function generateColumns() {
  const COLUMN_WIDTH = window.RPConfig.COLUMN_WIDTH
  return [
    {
      title: "服务名",
      key: "name"
    },
    {
      title: "分组名称",
      key: "groupName"
    },
    {
      title: "集群数目",
      key: "ipCount",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_4_WORDS,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_4_WORDS + COLUMN_WIDTH.MAX_WIDTH_MORE,
    },
    {
      title: "实例数",
      key: "clusterCount",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_3_WORDS,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_3_WORDS + COLUMN_WIDTH.MAX_WIDTH_MORE,
    },
    {
      title: "健康实例数",
      key: "healthyInstanceCount",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_5_WORDS,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_5_WORDS + COLUMN_WIDTH.MAX_WIDTH_MORE,
    },
    {
      title: "触发保护阈值",
      key: "triggerFlag",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_6_WORDS,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_6_WORDS + COLUMN_WIDTH.MAX_WIDTH_MORE,
    },
    {
      title: this.$t("common.operating"),
      align: "left",
      fixed: "right",
      width: 110,
      render: (h, { row }) => {
        return h("RowTools", {
          props: {
            data: [
              {
                type: "icon",
                icon: "ios-eye",
                text: "详情",
                handle: () => this.detailHandle({ ...row, namespaceId: this.formSearch.namespaceId })
              },
              {
                type: "icon",
                icon: "md-people",
                text: "订阅者",
                handle: () => this.goSubscriber(row)
              }
            ]
          }
        });
      }
    }
  ];
}

export function generatecolonyColumns() {
  return [
    {
      key: 'ip',
      title: 'IP'
    },
    {
      title: '端口',
      key: 'port'
    },
    {
      title: '临时实例',
      key: 'ephemeral'
    },
    {
      key: 'weight',
      title: '权重'
    },
    {
      key: 'healthy',
      title: '健康状态'
    },
    {
      key: 'metadata',
      title: '元数据',
      minWidth: 350,
    },
    {
      title: this.$t("common.operating"),
      align: "left",
      fixed: "right",
      width: 80,
      render: (h, { row }) => {
        return h("RowTools", {
          props: {
            data: [
              {
                type: "icon",
                icon: row.enabled ? 'md-cloud-download' : 'md-cloud-upload',
                text: row.enabled ? '下线' : '上线',
                handle: () => this.statusHandle(row)
              },
            ]
          }
        });
      }
    }
  ]
}
